Your application can use the SpeakString function to generate speech or stop speech currently being generated by SpeakString. By calling the SpeechBusy function before and after a call to SpeakString, your application can determine when speaking is complete. These routines belong to the Speech Manager.
You can use the SpeakString function to have the Speech Manager read a text string.
FUNCTION SpeakString (s: Str255): OSErr;
The SpeakString function attempts to speak the Pascal-style text string contained in the string s . Speech is produced asynchronously using the default system voice. When an application calls this function, the Speech Manager makes a copy of the passed string and creates any structures required to speak it. As soon as speaking has begun, control is returned to the application. The synthesized speech is generated asynchronously to the application so that normal processing can continue while the text is being spoken. No further interaction with the Speech Manager is required at this point, and the application is free to release the memory that the original string occupied.
If SpeakString is called while a prior string is still being spoken, the sound currently being synthesized is interrupted immediately. Conversion of the new text into speech is then begun. If you pass a zero-length string (or, in C, a null pointer) to SpeakString , the Speech Manager stops any speech previously being synthesized by SpeakString without generating additional speech. If your application uses SpeakString , it is often a good idea to stop any speech in progress whenever your application receives a suspend event. (Note, however, that calling SpeakString with a zero-length string has no effect on speech channels other than the one managed internally by the Speech Manager for the SpeakString function.)
The text passed to the SpeakString function may contain embedded speech commands, which are described in the chapter "Speech Manager" in this book.
Because the SpeakString function moves memory, you should not call it at interrupt time.
For an example of how to read a text string using the SpeakString function, see "Generating Speech From a String" . See the chapter "Dialog Manager" in Inside Macintosh: Macintosh Toolbox Essentials for a complete description of event filter functions.
You can use the SpeechBusy function to determine whether any channels of speech are currently synthesizing speech.
FUNCTION SpeechBusy: Integer;
The SpeechBusy function returns the number of speech channels that are currently synthesizing speech in the application. This is useful when you want to ensure that an earlier speech request has been completed before having the system speak again. Note that paused speech channels are counted among those that are synthesizing speech.
The speech channel that the Speech Manager allocates internally in response to calls to the SpeakString function is counted in the number returned by SpeechBusy . Thus, if you use just SpeakString to initiate speech, SpeechBusy always returns 1 as long as speech is being produced. When SpeechBusy returns 0, all initiated speech has finished.
| Previous | Chapter contents | Chapter top | Section top |